package com.spzx.JUC3.test2;

import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.TimeUnit;

public class EmployeeThread extends Thread{
    private CyclicBarrier cyclicBarrier;
    public EmployeeThread(CyclicBarrier cyclicBarrier) {
        this.cyclicBarrier = cyclicBarrier;
    }

    @Override
    public void run() {
        try {
            //Thread.sleep((int)(Math.random())*1000);
            TimeUnit.SECONDS.sleep(5);
            System.out.println(Thread.currentThread().getName()+"到了");
            cyclicBarrier.await();
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (BrokenBarrierException e) {
            throw new RuntimeException(e);
        }
    }
}
